package apweb;

public class ToolsCollections {

	/**
	 * @param args
	 */
	//given 1 2 a and 3 4 b
	//return 1 2 3 4 ab
	public static String combine(String leftValue, String rightValue)
	{
		String[] la = leftValue.split("\t");
		String[] ra = rightValue.split("\t");
		String value=arrayListToString(la, "\t", la.length-2);
		value += "\t"+arrayListToString(ra, "\t", ra.length-2);
		value += "\t"+la[la.length-1]+ra[ra.length-1];
		return value;
	}
	private static String arrayListToString(String[] arlist, String delimiter, int endIndex) {
        StringBuilder arlstTostr = new StringBuilder();
        if (arlist.length > 0) {
            arlstTostr.append(arlist[0]);
            for (int i=1; i<arlist.length && i<=endIndex; i++) {
                arlstTostr.append(delimiter);
                arlstTostr.append(arlist[i]);
            }
        }
        return arlstTostr.toString();
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
